﻿using System;

namespace Catchbase.Service.API
{
    public class CatchbaseUriBuilder
    {
        protected CatchbaseUriBuilder()
        {
        }

        public CatchbaseUriBuilder(string baseUri)
        {
            UriBuilder = new UriBuilder(baseUri);
        }

        private UriBuilder UriBuilder { get; set; }

        public virtual Uri Build<T>()
        {
            UriBuilder.Path = GetPath<T>();
            return UriBuilder.Uri;
        }

        public virtual Uri Build<T>(string someid)
        {
            Build<T>();
            UriBuilder.Path += "/" + someid;
            return UriBuilder.Uri;
        }

        private static string GetPath<T>()
        {
            return string.Format("{0}", typeof (T).Name.ToLower());
        }
    }
}